{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The contents of Panelite are updated on every release, however Jupyterlite caches old edits to files. If you want to reset the storage and **delete all modifications you made to the contents** then run the code below and click the button `Clear JupyterLite local storage` button."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import display, HTML\n",
    "display(HTML(\"\"\"\n",
    "<button type=\"button\" id=\"button_for_indexeddb\">Clear JupyterLite local storage</button>\n",
    "<div id=\"clear-storage-message\"></div>\n",
    "<script>\n",
    "window.button_for_indexeddb.onclick = function(e) {\n",
    "    message = document.getElementById(\"clear-storage-message\")\n",
    "    message.innerText=\"Running\"\n",
    "    window.indexedDB.open('JupyterLite Storage').onsuccess = function(e) {\n",
    "        // There are also other tables that I'm not clearing:\n",
    "        // \"counters\", \"settings\", \"local-storage-detect-blob-support\"\n",
    "        let tables = [\"checkpoints\", \"files\"];\n",
    "\n",
    "        let db = e.target.result;\n",
    "        let t = db.transaction(tables, \"readwrite\");\n",
    "\n",
    "        function clearTable(tablename) {\n",
    "            let st = t.objectStore(tablename);\n",
    "            st.count().onsuccess = function(e) {\n",
    "                console.log(\"Deleting \" + e.target.result + \" entries from \" + tablename + \"...\");\n",
    "                st.clear().onsuccess = function(e) {\n",
    "                    console.log(tablename + \" is cleared!\");\n",
    "                }\n",
    "            }\n",
    "        }\n",
    "\n",
    "        for (let tablename of tables) {\n",
    "            clearTable(tablename);\n",
    "        }\n",
    "    }\n",
    "    message.innerText=\"JupyterLite local storage has successfully been reset\"\n",
    "};\n",
    "</script>\n",
    "\"\"\"))"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
